import { defHttp } from '@/utils/http/axios'

enum Api {
  CLASSIFY_TREE = '/classify/tree',
  CLASSIFY_DEVICE_PAGE = '/classify/device/page',
  DELETE_CLASSIFY = '/classify/delete',
  CLASSIFY_DETAIL = '/classify/detail',
  CLASSIFY_DEVICELIST = '/classify/deviceList',

  ADD_UPDATE_CALSSIFY = '/classify/addOrUpdate',
  DELETE_CLASSIFY_DEVICE = '/classify/device/delete',
  ADD_CLASSIFY_DEVICE = '/classify/device/add',
  GET_CLASSIFY_LIST_BY_PARENT = '/classify/getByParent',
  // 根据父id获取下面的树
  GET_CLASSIFY_TREE_LIST_BY_PARENT = '/classify/tree/parent',
  GET_LIST_CLASSIFY_TREE = '/group/tree',
  ADD_OR_UPDATE_LIST_CLASSIFY = '/group/addOrUpdate',
  GET_DETAIL_LIST_CLASSIFY = '/group/info',
  DEL_LIST_CLASSIFY = '/group/delete'
}

export const addOrUpdateClassify = (data) => defHttp.post({ url: Api.ADD_UPDATE_CALSSIFY, data })
export const deleteClassifyDevice = (data) =>
  defHttp.post({ url: Api.DELETE_CLASSIFY_DEVICE, data })
export const addClassifyDevice = (data) => defHttp.post({ url: Api.ADD_CLASSIFY_DEVICE, data })
export const getClassifyTree = (params) => defHttp.get({ url: Api.CLASSIFY_TREE, params })
export const getClassifyDevice = (params) => defHttp.get({ url: Api.CLASSIFY_DEVICE_PAGE, params })
export const deleteClassify = (params) => defHttp.get({ url: Api.DELETE_CLASSIFY, params })
export const getClassifyDetail = (params) => defHttp.get({ url: Api.CLASSIFY_DETAIL, params })
export const getClassifyDeviceList = (params) =>
  defHttp.get({ url: Api.CLASSIFY_DEVICELIST, params })
export const getClassifyByPatent = (params) =>
  defHttp.get({ url: Api.GET_CLASSIFY_LIST_BY_PARENT, params })
export const getClassifyTreeByPatent = (params) =>
  defHttp.get({ url: Api.GET_CLASSIFY_TREE_LIST_BY_PARENT, params })

export const getlistClassifyTree= (params?) => defHttp.get({url: Api.GET_LIST_CLASSIFY_TREE, params})
export const getlistClassifyTreeDetail= (params?) => defHttp.get({url: Api.GET_DETAIL_LIST_CLASSIFY, params})
export const addorupdateListClassify = (data) => defHttp.post({url: Api.ADD_OR_UPDATE_LIST_CLASSIFY, data})
export const delListClassify = (data) => defHttp.post({url: Api.DEL_LIST_CLASSIFY, data})
export const getClassifyTreeByDeviceCode = (params) => defHttp.get({url: `/classify/getClassifyTreeByDeviceCode`, params})
export const exportClassifyTree = (params) => defHttp.get({url:`/classify/exportTree`, params, responseType: 'blob'})
